home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / halt < prev    next >
Encoding:
Text File  |  2006-10-06  |  1.2 KB  |  78 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          halt
  4. # Required-Start:    umountroot
  5. # Required-Stop:
  6. # Should-Start:      lvm raid2
  7. # Should-Stop:
  8. # Default-Start:     0
  9. # Default-Stop:
  10. # Short-Description: Execute the halt command.
  11. # Description:
  12. ### END INIT INFO
  13.  
  14. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  15. [ -f /etc/default/halt ] && . /etc/default/halt
  16.  
  17. . /lib/lsb/init-functions
  18.  
  19. do_stop () {
  20.     if [ "$INIT_HALT" = "" ]
  21.     then
  22.         case "$HALT" in
  23.           [Pp]*)
  24.             INIT_HALT=POWEROFF
  25.             ;;
  26.           [Hh]*)
  27.             INIT_HALT=HALT
  28.             ;;
  29.           *)
  30.             INIT_HALT=POWEROFF
  31.             ;;
  32.         esac
  33.     fi
  34.  
  35.     # See if we need to cut the power.
  36.     if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ]
  37.     then
  38.         /etc/init.d/ups-monitor poweroff
  39.     fi
  40.  
  41.     # Don't shut down drives if we're using RAID.
  42.     hddown="-h"
  43.     if grep -qs '^md.*active' /proc/mdstat
  44.     then
  45.         hddown=""
  46.     fi
  47.  
  48.     # If INIT_HALT=HALT don't poweroff.
  49.     poweroff="-p"
  50.     if [ "$INIT_HALT" = "HALT" ]
  51.     then
  52.         poweroff=""
  53.     fi
  54.  
  55.     log_action_msg "Will now halt"
  56.     sleep 1
  57.     halt -d -f -i $poweroff $hddown
  58. }
  59.  
  60. case "$1" in
  61.   start)
  62.     # No-op
  63.     ;;
  64.   restart|reload|force-reload)
  65.     echo "Error: argument '$1' not supported" >&2
  66.     exit 3
  67.     ;;
  68.   stop)
  69.     do_stop
  70.     ;;
  71.   *)
  72.     echo "Usage: $0 start|stop" >&2
  73.     exit 3
  74.     ;;
  75. esac
  76.  
  77. :
  78.